package com.zzptc.lhl.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;

import com.zzptc.lhl.myapplication.entity.Qichepinpai;
import com.zzptc.lhl.myapplication.service.QinchePinpaiservice;

import java.util.HashMap;
import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "MainActivity";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getQichepinpaiInfo();
    }

    private void getQichepinpaiInfo() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("http://apis.juhe.cn/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        QinchePinpaiservice qinchepinpaiservice = retrofit.create(QinchePinpaiservice.class);
        Map<String,String>map=new HashMap<>();
        map.put("key","79729168b7661c89f1f4e56936121f31");
        map.put("first_letter","D");
        Call<Qichepinpai>allpinpai=qinchepinpaiservice.getAllpinpai(map);
        allpinpai.enqueue(new Callback<Qichepinpai>() {
            @Override
            public void onResponse(Call<Qichepinpai> call, Response<Qichepinpai> response) {

            }

            @Override
            public void onFailure(Call<Qichepinpai> call, Throwable t) {

            }
        });
       /*Call<Qichepinpai> allpinpai = qinchepinpaiservice.getAllpinpai("79729168b7661c89f1f4e56936121f31", "A");
        allpinpai.enqueue(new Callback<Qichepinpai>() {
            @Override
            public void onResponse(Call<Qichepinpai> call, Response<Qichepinpai> response) {
                Qichepinpai body = response.body();
                Log.d(TAG, "onResponse: "+body.getResult().size());
            }

            @Override
            public void onFailure(Call<Qichepinpai> call, Throwable t) {

            }
        });*/
    }
}
